<template>
  <div>
    <AplidForm
      ref="formRef"
      v-bind="ExtendFormConfig"
      v-model="formModel"
      @submit="onSubmit">
    </AplidForm>
  </div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod'
import { ExtendFormConfig } from '@/views/datacenter/basicData/serviceFacility/config'
// import { getAreaObj } from '@/utils/util'
// import { useCommonStore } from '@/stores/common'

const emit = defineEmits(['refresh','gatherParams'])
// 接受一下父组件出传过来的数据,实际是第一个表单的数据
const props = defineProps(['baseInfo'])

const formModel = ref({})
const formRef = ref(null)

const onSubmit = (form, done) => {
  console.log('字段',form,props.baseInfo)
  // const { tempNowObj } = storeToRefs(useCommonStore())
  // console.log(tempNowObj.value, 'tempNowObjtempNowObj-，拿到之前的数据')
  const params = {
      ...form,
      soleValue: props.baseInfo.soleValue,
      code:2003
  }
  // 直接提交需要走这
  emit('gatherParams',params)
  apiMod.dpServiceFacilityExtend_gather(params).then(res=>{
    // 传给第三个表
    emit('refresh', res.data)
    done()
  }).catch(err=>{
    done()
  })
  
}

const onSave = () => {
  formRef.value!.onSubmit()
}
defineExpose({
  onSave
})
</script>

<style scoped></style>
